<?php

// $Id$

require_once(TANGRA_MAIN_DIR.'filesystem_toolbox/filesystem_functions.inc.php');

require_once($WSC->get_site_inc_dir().'modules/tangra_cms/_sys/tcms_admin_web_page_wed_ua.class.php');


class Cache_Clear_WP extends TCMS_Admin_Web_Page_WED_UA {
	public function create_view($name = 'default') {
		$ret = new TCMS_Admin_Page_View($this, $name, 'modules/tangra_cms/pages/_vpage/');

		return $ret;
	}


	public function init() {
		parent::init();

		$v = $this->create_view();
		$this->add_view($v);

		$v2 = $this->create_view('cache_cleared');
		$this->add_view($v2);

		$this->wed->add_wed_event_action_pair(new Web_Event_Simple_Int('clear_confirmed', Tangra_Parameter_Method::GET, 'clear_confirmed'), 'clear_confirmed');
	}


	protected function default_event() {
		$view = $this->get_view('default');

		return $view;
	}


	protected function clear_confirmed() {
		$view = $this->get_view('cache_cleared');

		empty_dir($this->_config->get_scratch_dir().'tcms_cache');

		return $view;
	}
}